home *** CD-ROM | disk | FTP | other *** search
- Path: keats.ugrad.cs.ubc.ca!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.lang.c
- Subject: Re: Problem Negating an Unsigned Char
- Date: 4 Mar 1996 12:42:46 -0800
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Message-ID: <4hfkk6INN2tm@keats.ugrad.cs.ubc.ca>
- References: <Dnnros.Lq.0.-s@hkusuc.hku.hk> <4he27sINNdel@keats.ugrad.cs.ubc.ca> <4he5f0$acv@solutions.solon.com>
- NNTP-Posting-Host: keats.ugrad.cs.ubc.ca
-
- In article <4he5f0$acv@solutions.solon.com>,
- Peter Seebach <seebs@solutions.solon.com> wrote:
- >In article <4he27sINNdel@keats.ugrad.cs.ubc.ca>,
- >Kazimir Kylheku <c2a192@ugrad.cs.ubc.ca> wrote:
- >>To make it portable, you must manually mask for the lower eight bits:
- >
- >> if (a == (~b & 0xff))
- >
- >Close, but the cigar yet escapes you.
-
- No it does not. I _wanted_ eight bit arithmetic, not CHAR_BIT arithmetic.
-
- > if (a == (~b & ((1 << CHAR_BIT) - 1)))
- >
- >Further, you can't do this portably; if sizeof(long) is 1, the
- >shift is illegal.
-
- Your shift, not mine!
-
- I would just AND with UCHAR_MAX. I don't think there is any possibility that it
- could be anything other than a dyadic power, less one.
- --
-
-